package tt.dz.egobus.servicemanager.business.lock;

import tt.dz.egobus.cache.service.ExtendCacheService;
import tt.dz.egobus.servicemanager.core.lock.AbstractRedisCacheLock;

/**
 * @author Anson
 * @date 17-8-9
 * @name 派车业务分布式锁
 * @since 1.0.6
 */
public class BusinessRedisLock extends AbstractRedisCacheLock implements BusinessLock {

    private final ExtendCacheService service;

    public static final String BUSINESS_LOCK = "EGOBUS_BUSINESS_LOCK";

    /**
     * 当前业务流水号
     */
    private String businessId;

    public BusinessRedisLock(ExtendCacheService service) {
        this.service = service;
    }


    @Override
    protected ExtendCacheService cacheService() {
        return this.service;
    }

    @Override
    protected String getLockKey() {
        return BUSINESS_LOCK + "_" + this.businessId;
    }

    @Override
    public void setBusinessId(String businessId) {
        this.businessId = businessId;
    }

    @Override
    public String businessId() {
        return this.businessId;
    }
}
